package kandl.automation;

public class Browser {

    public static final String CHROME_TYPE = "CHR";
    public static final String FIREFOX_TYPE = "FF";
    public static final String IE_TYPE1 = "IE8";
    public static final String IE_TYPE2 = "IE9";
    public static final String IE_TYPE3 = "IE10";
    public static final String IE_TYPE4 = "IE11";
    public static final String SAFARI_TYPE = "Safari";
    public static final String IPHONE_TYPE = "Safari_phone";
    public static final String IPAD_TYPE = "Safari_ipad";
    public static final String ANDROID_PHONE_TYPE = "Android_phone";
    public static final String ANDROID_TABLET_TYPE = "Android_ipad";

    private final String id;
    private final String name;

    public Browser(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getType() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String toString() {
        return name;
    }

    public static Browser firefox() {
        return new Browser(FIREFOX_TYPE, "Firefox");
    }
    public static Browser ie8() {
        return new Browser(IE_TYPE1, "IE8");
    }

    public static Browser ie9() {
        return new Browser(IE_TYPE2, "IE9");
    }
    public static Browser ie10() {
        return new Browser(IE_TYPE3, "IE10");
    }
    public static Browser ie11() {
        return new Browser(IE_TYPE4, "IE11");
    }

    public static Browser chrome() {
        return new Browser(CHROME_TYPE, "Chrome");
    }

    public static Browser safari() {
        return new Browser(SAFARI_TYPE, "Safari");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Browser browser = (Browser) o;

        if (id != null ? !id.equals(browser.id) : browser.id != null) return false;
        if (name != null ? !name.equals(browser.name) : browser.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        return result;
    }
}
